<template>
    <div id="Table">
        <v-table
            :page="page"
            :pageSize="pageSize"
            :tableConfig="tableConfig"
            :tableData="tableData"
            :total="total"
            @findData="getTableData"
            @getTableData="getTableData"
            @selectData="setSelectData"
            @setdialog="setdialog"
            @upData="getTableData"
            ref="table"
        ></v-table>
    </div>
</template>

<script>
import table from "commons/Table";
import baseMixin from "@/mixins/BaseMixin";

export default {
    name: "Table",
    mixins: [baseMixin],
    props: {
        data: {
            type: Object
        }
    },
    data() {
        return {
            tableConfig: [
                {
                    label:'common.code',
                    prop: "code",
                    input: "input"
                },
                {
                    label: 'common.desc',
                    prop: "description",
                    input: "input"
                },
                {
                    label: 'config.serial',
                    prop: "serialkey",
                    input: "input"
                },
                {
                    label: 'config.activityStatus',
                    prop: "active",
                    input: "select",
                    options: [
                        {description: this.$t('code.activate'), code: "1"},
                        {description: this.$t('code.unactivate'), code: "0"},
                    ]
                },
                {
                    label: this.$t('config.activityStatus') + "1",
                    prop: "udf1",
                    input: "input"
                },
                {
                    label: this.$t('config.activityStatus') + "2",
                    prop: "udf2",
                    input: "input"
                },
                {
                    label: this.$t('config.activityStatus') + "3",
                    prop: "udf3",
                    input: "input"
                },
                {
                    label: this.$t('config.activityStatus') + "4",
                    prop: "udf4",
                    input: "select",
                    options: this.getOptions('querycodeLkup/YESNO')
                },
                {
                    label: this.$t('config.activityStatus') + "5",
                    prop: "udf5",
                    input: "input"
                },
                {
                    label: this.$t('config.activityStatus') + "6",
                    prop: "udf6",
                    input: "input"
                },
                {
                    label: this.$t('config.lastUpdate'),
                    prop: "editdate",
                    input: "date"
                },
                {
                    label: this.$t('config.lastUpName'),
                    prop: "editwho",
                    input: "input"
                },
            ],
            tableData: [],
          page: 1,
            pageSize: 10,
            total: 10,
            tableSearhData: {},
        }
    },
    methods: {
        //获取table数据
        async getTableData(page, data) {
            try {
                let res = await this.$api.post(`/queryCodelkupList/${this.$store.state.wms}/${this.data.argument.listname}/${page}`, data);
                
                    this.tableData = res.page.list;
                    // this.$store.commit("setTemporary",this.tableData);
                    this.pageSize = res.page.pageSize;
                  this.page = res.page.curpage;
                    this.total = res.page.total;
                
            } catch (e) {
                this.$message.error(e);
            } finally {
                this.loading = false;
            }

        },
        //搜索的值
        searhData(data, up) {
            if (!up) {
                this.tableSearhData = data;
            } else {
                this.tableSearhData = data;
                this.getTableData(1, this.tableSearhData);
            }
        },
        //选中的数据
        setSelectData(data) {
            this.$parent.selectData = data;
        },
        //进入详情
        async setdialog(data) {
            this.$parent.enterDetails(data);
        },
    },
    mounted() {
        this.getTableData(1, {})
    },
    components: {
        "v-table": table
    }
}
</script>

<style scoped>

</style>
